﻿using mars_client.csharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Newtonsoft.Json;
using mars_client.csharp.enums;
using mars_client.csharp.vo;
using mars_client.csharp.model;
using mars_client.csharp.radar;
using mars_client.csharp.util;
using mars_client.csharp.controller;

namespace mars_client.gui.window
{
    /// <summary>
    /// Login.xaml 的交互逻辑
    /// </summary>
    public partial class LoginWindow : Window
    {
        Radar r;
        public LoginWindow()
        {
            InitializeComponent();
            GuiCache guic = GuiCache.Instance;
            guic.setGui("LoginWindow", this);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void closeImg_MouseUp(object sender, MouseButtonEventArgs e)
        {
            System.Environment.Exit(0);
        }
        public void DragWindow(object sender, MouseButtonEventArgs args)
        {
            this.DragMove();
        }
        private void minImg_MouseUp(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void TextBox_MouseUp(object sender, MouseButtonEventArgs e)
        {
            r = Radar.Instance;
            // 封装协议体
            LoginVO loginVO = new LoginVO();
            loginVO.username = usernameBox.Text;
            loginVO.password = passwordBox.Password;
            MessageCO co = new MessageCO();
            co.type = (int)RequestEnum.request.Login;
            co.content = loginVO;
            if (r != null)
                r.sendData(co);
        }
    }
}
